<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">

	<input type="hidden" id="phone" th:value="${phone.phone}" >
	<input type="hidden" id="flag" th:value="${phone.flag}" >
	<input type="hidden" id="craBeginTime" th:value="${phone.craBeginTime}" >
	<input type="hidden" id="craEndTime" th:value="${phone.craEndTime}" >


	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-user-add">
			<input name="deptId"  type="hidden" id="treeId"/>
			<div class="form-group">
				<label class="col-sm-3 control-label ">标签：</label>
				<div class="col-sm-7">
					<label th:each="flag:${labels}" class="check-box">
						<input name="flag" type="checkbox" th:value="${flag.label}" th:text="${flag.label}">
					</label>
				</div>
			</div>
		</form>
	</div>
	<div th:include="include::footer"></div>
	<script th:src="@{/ajax/libs/select/select2.js}"></script>
	<script>
        function submitHandler() {
	        if ($.validate.form()) {
	        	add();
	        }
	    }

        function add() {
           var flags = $.form.selectCheckeds("flag");

            var phone = $('#phone').val();
            var flag = $('#flag').val();
            var craBeginTime = $('#craBeginTime').val();
            var craEndTime = $('#craEndTime').val();
            var url = '&phone='+phone+'&flag='+flag;
            url += '&craBeginTime='+craBeginTime+'&craEndTime='+craEndTime;

           $.ajax({
                cache : true,
                type : "POST",
                url : ctx + "phone/addFlags?1=1"+url,
                data : {
                    "flags": flags
                },
                async : false,
                error : function(request) {
                    $.modal.alertError("系统错误");
                },
                success : function(data) {
                    $.operate.successCallback(data);
                }
           });
        }

    </script>
</body>
</html>
